<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link href="lib/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<link href="lib/bootstrap-validator/css/bootstrapValidator.min.css" rel="stylesheet" type="text/css" />
		<style>
			body {
				overflow-x: hidden;
			}
			
			.form-group {
				margin-bottom: 10px;
			}
			
			.control-label {
				text-align: right;
				margin-top: 8px;
				padding-right: 0;
			}
		</style>
	</head>

	<body>
		<form id='form' class="form-horizontal">
			<div class="form-group">
				<label class="col-xs-3 control-label">原密码：<span class="text-danger">*</span></label>
				<div class="col-xs-8">
					<input id="old_pwd" type="password" class="form-control" name="oldPassword" placeholder="请输入原密码..." />
				</div>
			</div>

			<div class="form-group">
				<label class="col-xs-3 control-label">新密码：<span class="text-danger">*</span></label>
				<div class="col-xs-8">
					<input id="new_pwd" type="password" class="form-control" name="newPassword" placeholder="请输入新密码..." />
				</div>
			</div>

			<div class="form-group">
				<label class="col-xs-3 control-label">确认新密码：<span class="text-danger">*</span></label>
				<div class="col-xs-8">
					<input type="password" class="form-control" name="confirmPassword" placeholder="请再次输入新密码..." />
				</div>
			</div>
		</form>
	</body>

	<script src="lib/requirejs/require.min.js"></script>
	<script src="js/vw.config.require.js"></script>
	<script>
		var _vali;

		//验证
		require(['bootstrap.validator-cn', "md5"], function() {
			_vali = $('#form').bootstrapValidator({
				message: '输入的内容无效',
				feedbackIcons: {
					valid: 'glyphicon glyphicon-ok',
					invalid: 'glyphicon glyphicon-remove',
					validating: 'glyphicon glyphicon-refresh'
				},
				fields: {
					oldPassword: {
						validators: {
							notEmpty: {
								message: '密码不能为空'
							}
						}
					},
					newPassword: {
						validators: {
							notEmpty: {
								message: '密码不能为空'
							},
							identical: {
								field: 'confirmPassword',
								message: '两次输入的内容不一致'
							}
						}
					},
					confirmPassword: {
						validators: {
							notEmpty: {
								message: '密码不能为空'
							},
							identical: {
								field: 'newPassword',
								message: '两次输入的内容不一致'
							}
						}
					},
				}
			});
			_vali.on('success.form.bv', function(e) {
				vw_common.customAjax({
					url: VW_INTERFACE.WEBSERVICE.LoginManage("ChangePwd"),
					type: 'POST',
					dataType: 'json',
					data: {
						userID: vw_static.getCookie(window.location.host),
						oldPwd:  hex_md5(String($('#old_pwd').val())),
						newPwd: hex_md5(String($('#new_pwd').val()))
					},
				}, function(e) {
					bDialog.msgPopup("success", "成功", "密码修改成功请重新登陆!");
					window.parent.location.href = VW_INTERFACE.PAGES.LOGIN;
				});
			});

		});

		//提交保存
		function save() {
			require(['bootstrap.validator-cn'], function() {
				_vali.bootstrapValidator('validate');
			});
		}
	</script>

</html>